import { QXEvent } from "qx-util";
import { IParam, CalendarActionType, ICalendarAbility, ICalendarControllerParams, ICalendarStore, CalendarController, ICtrlEvent, ICalendarController, ICalendarModel, ControlVOBase } from "@/core";
import { useCalendarAction, useCalendarBasic, useCalendarControllerParams, useCalendarProps } from "@/hooks/widget/use-calendar";
import { CalendarControlVO } from './book-calendar-major-state-calendar-vo';
import { model } from "./book-calendar-major-state-calendar-model";
import CalendarService from "@/core/modules/ctrl-service/calendar-service";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@CALENDAR}}-calendar/{{spinalCase ctrl.codeName}}-calendar-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useCalendarProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useCalendarBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useCalendarAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<CalendarActionType, ICalendarAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<CalendarActionType, ICalendarAbility>>,
    otherParams: IParam = {},
): ICalendarController<ICalendarStore, ICalendarAbility> {
	const params: ICalendarControllerParams<CalendarActionType, ICalendarAbility> =
		useCalendarControllerParams<ICalendarStore, ICalendarModel>(model, props, evt, otherParams);
    const ctrlService = new CalendarService<ControlVOBase[]>(CalendarControlVO, model.entityCodeName, { model });
  	Object.assign(params, { ctrlService });
  	return new CalendarController(params);
}